# -*- coding: utf-8 -*-

# @Project : UI_DDTFrameWork
# @Author  : Mr.Deng
# @Time    : 2021/9/22 1:43

from common.seleniumLibrary import PySelenium
from common.tools.assertion import Assertion
from common.tools.getTestData import get_data
from common.tools.decorator import skip_case

from page.baiduSetPage import BaiDuSetPage

import unittest
import ddt


@ddt.ddt
class BaiDuSet(unittest.TestCase):
    """
    百度首页设置测试用例
    """

    @classmethod
    def setUpClass(cls):
        """实例化类文件"""
        cls.driver = PySelenium()
        cls.baiduSetPage = BaiDuSetPage(cls.driver)
        cls.assertion = Assertion(cls.driver)

    @ddt.data(*get_data(fileName="homeSetData.yaml"))
    @skip_case
    def test_baidu_set(self, testData):
        """
        百度首页设置测试用例
        :param testData: 测试数据
        :return:
        """
        self.baiduSetPage.open_search_home_page()
        self.driver.Log.info(f"测试用例名称：{testData['caseName']}")
        self.baiduSetPage.move_set_btn()
        self.baiduSetPage.click_hide_show_info_btn(testData["testData"])
        self.driver.refresh_browser()
        self.driver.sleep(2)
        # 断言判断搜索首页是否显示热搜组件
        hotSearchIsVisible = self.baiduSetPage.get_hot_search_btn_att()
        self.assertion.assert_equal(testData["expectation"], hotSearchIsVisible)

    @classmethod
    def tearDownClass(cls):
        cls.driver.quit()


if __name__ == '__main__':
    suit = unittest.TestLoader().loadTestsFromTestCase(BaiDuSet)
    unittest.TextTestRunner().run(suit)
